﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;

namespace AngelPerez.Taringa.PostEdit {
	public class PostEditor : Control {
		/* Private members. */
		private Point _CaretPosition = new Point(0, 0);
		private List<Control> _Objects = new List<Control>();

		/* Public properties. */
		public Point CaretPosition {
			get { return _CaretPosition; }
			set { _CaretPosition = value; }
		}

		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public List<Control> Objects {
			get { return _Objects; }
			set { _Objects = value; }
		}

		/* Constructors. */
		public PostEditor() {

		}

		/* Events. */
		protected override void OnPaint(PaintEventArgs e) {
			base.OnPaint(e);
			
			// Render objects.
			foreach (Control obj in this.Objects) {
				Bitmap renderedObject = new Bitmap(obj.Width, obj.Height);
				obj.DrawToBitmap(renderedObject, obj.Bounds);

				e.Graphics.DrawImage((Image)renderedObject, obj.Location);
			}

			// Draw caret.
			
		}
	}
}
